package cn.yangliu.nacos.management.entity.sys;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Table;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * The type of nacos.
 *
 * @author 问道于盲
 * @date 2020 -01-01
 */
@Entity
@Table(name = "cm_user_role")
@Data
public class User2Role {

    /**
     * current class instance's member.
     * The Id.
     */
    @EmbeddedId
    private User2RoleKey id;

    /**
     * The interface User 2 role key.
     *
     * @author 问道于盲
     */
    @Embeddable
    @Data
    @NoArgsConstructor
    public static class User2RoleKey implements Serializable {

        /**
         * current class's static member
         * The constant serialVersionUID.
         */
        private static final long serialVersionUID = 4047248841510563806L;

        /**
         * current class instance's member.
         * The User id.
         */
        @Column(name = "user_id")
        private Long userId;

        /**
         * current class instance's member.
         * The Role id.
         */
        @Column(name = "role_id")
        private Long roleId;

        /**
         * Instantiates a new User 2 role key.
         * allow any class to create a new instance.
         *
         * @param userId the user id
         * @param roleId the role id
         */
        public User2RoleKey(Long userId, Long roleId) {
            this.userId = userId;
            this.roleId = roleId;
        }
    }
}
